<div class="content <%= installation.status %>">
  <div class="title">
    <div class="name"><%= installation.installer.try(:full_name) %></div>
    <div class='mobile'>
      <%= installation.installer.try(:mobile) %>
    </div>
    <div class='status corner'>
      <%= t installation.status %>
    </div>
    <div class='installation_form_no'>
      <%= installation.install_no %>
    </div>
  </div>
  <div class='fields'>
    <dl>
      <dt>预订单号:</dt>
      <dd><%= link_to installation.order.order_no, installation.order, :class => :order_no, :target => :_blank %></dd>
      <dt>预订日期:</dt>
      <dd><%= installation.order.ordered_on %></dd>
    </dl>
    <dl>
      <dt>安装日期:</dt>
      <dd><%= installation.installed_on %></dd>
    </dl>
    <dl>
      <dt>应收金额:</dt>
      <dd><%= number_with_precision(installation.should_be_payed_price, :precision => 2) %></dd>
      <dt>实收金额:</dt>
      <dd><%= number_with_precision(installation.payed_price, :precision => 2) %></dd>
    </dl>
    <dl>
      <dt>顾客电话:</dt>
      <dd class='l'><%= installation.order.buyer.try(:full_name) %> <%= installation.order.buyer.try(:mobile) %> <%= installation.order.buyer.try(:link_phone) %></dd>
    </dl>
    <dl>      
      <dt>交货地址:</dt>
      <dd class='l'><%= installation.order.buyer.try(:address) %></dd>
    </dl>
  </div>    
  <div class='furnitures'>
    <table cellspacing='1' cellpadding='1'>
      <tr>
        <th>型号</th>
        <th>名称</th>
        <th>材质</th>
        <th>规格</th>
        <th>数量</th>
        <th>动态</th>
      </tr>
      <% installation.install_items.each do |item| %>
      <tr id='item_<%= item.id %>' class='install_item <%= cycle '','hh', :name => 'install_item' %>'>
        <td><%= item.furniture.furniture_style.code %></td>
        <td><%= item.furniture.furniture_style.name %></td>
        <td><%= item.furniture.material.code %>-<%= item.furniture.material.name %></td>
        <td><%= item.furniture.spec %></td>
        <td><%= item.installed_count %></td>
        <td>
          <%= t item.last_feed.code %>
        </td>
      </tr>
      <tr id='events_<%= item.id %>' class='item_events'>
        <td colspan='6'>
          <table class='events' cellspacing="1" cellpadding="1">
            <tr>
              <th></th>
              <th>描述</th>
              <th>登记人</th>                    
            </tr>
            <% item.feeds.each_with_index do |feed,index| %>
            <tr class='<%= cycle '','hh', :name => 'event' %>'>
              <td><%= index + 1 %>.</td>
              <td class='d'><%=raw feed.short_desc %><%= raw feed.remark.present? ? "<br/><b>备注：</b>#{raw(feed.remark) }" : '' %></td>
              <td><%= installation.creator.full_name %></td>                    
            </tr>
            <% end %>
          </table>
        </td>
      </tr>
      <script type="text/javascript" charset="utf-8">
        $('#item_<%= item.id %>').toggle(
          function() {
            $(this).addClass('h');
            $('#events_<%= item.id %>').show('slow');
          },
          function() {
            $(this).removeClass('h');
            $('#events_<%= item.id %>').hide();
          }
        );
      </script>
      <% end %>
    </table>
  </div>
  <% if installation.remark.present? %>
  <dl class="remark">
    <dt>特殊说明:</dt> 
    <dd><%= installation.remark %></dd>
  </dl>
  <% end %>
</div>
<div class="operate">
  <%= link_to "查看详情", installation_url(installation) , :class => :button, :target => :_blank %>
  <%= link_to installation.status.being_edited? ? "继续编辑" : (installation.status.blanked_out? ? "重新打开" : "编辑订单"), edit_installation_url(installation) , :class => :button %>
  <%= link_to "作废此单", installation_url(installation) , :remote => true, :method => :delete, :class => :button if not installation.status.blanked_out? %>
</div>